#include "Input.h"

Input::Input()
{
}

void Input::PopulateActionList( EnumState state )
{
    switch ( state )
    {
        case MENU:
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::Return, (int)STATE_GAME ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::F4, (int)STATE_EXIT ) );
        break;

        case GAME:
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::W, (int)PLAYER_1_MOVE_UP ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::S, (int)PLAYER_1_MOVE_DOWN ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::D, (int)PLAYER_1_ATTACK ) );

            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::Up,   (int)PLAYER_2_MOVE_UP ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::Down, (int)PLAYER_2_MOVE_DOWN ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::Left, (int)PLAYER_2_ATTACK ) );

            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::F4,       (int)STATE_MENU ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::F5,       (int)TOGGLE_FULLSCREEN ) );
            m_keyActionList.push_back( sader::BaseKeyAction( sf::Key::Return,   (int)TOGGLE_PAUSE ) );
        break;

        default:
            std::cout<<"Error: Trying to init input for invalid state"<<std::endl;
        break;
    };
}

std::vector<bool> Input::Actions()
{
    std::vector<bool> keyList( ACTION_COUNT );

    for (   std::vector<sader::BaseKeyAction>::const_iterator keyAction = m_keyActionList.begin();
            keyAction != m_keyActionList.end();
            ++keyAction )
    {
        keyList[ keyAction->m_action ] = GetKey( keyAction->m_keyCode );
    }

    return keyList;
}




